#include<bits/stdc++.h>
using namespace std;
long long n,l,r,cnt;
int main() {
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%lld%lld%lld",&n,&l,&r);
	cnt=l%n;
	for(int i=l+1; i<=r; i++) if(i%n>cnt)cnt=i%n;
	printf("%lld",cnt);
	fclose(stdin);
	fclose(stdout);
	return 0;
}
